<template>
	<div style="padding:0;width:1000px;margin-left: 90px;">
		<!-- 个人中心用户信息显示，及操作选项 -->
		<div style="float: left; width:25%;margin-top: 30px;width: 260px;">
			<!-- 个人信息 -->
			<div style="text-align: center;">
				<div style="height: 150px;">
					<img style="border-radius:30px;" width="100%" height="150px" :src="imgurl+user.tx">
				</div>
				<!-- 用户名 -->
				<span style="margin-top: 10px; font-size: 35px;">{{user.username}}</span> <br>
				<!-- 是否实名认证（选择显示） -->
				<el-button type="success" v-show="user.idcardstatus==1">已实名认证</el-button>
				<el-button type="danger" v-show="user.idcardstatus==0" @click="dialogFormVisible = true">未实名认证
				</el-button>
				<el-button type="warning" v-show="user.idcardstatus==0" @click="idCardStatusDialog=true">查看实名状态</el-button>

			</div>
			<!-- 操作选项 -->
			<el-menu style="text-align: center; background-color: #E9EEF3;" default-active="2"
				class="el-menu-vertical-demo" @close="handleClose">
				<el-menu-item index="2">
					<span @click="tomzc">我的众筹</span>
					<i class="el-icon-s-unfold"></i>
				</el-menu-item>
				<el-menu-item index="1">
					<span @click="tozc">资产总览</span>
					<i class="el-icon-s-unfold"></i>
				</el-menu-item>
				<el-menu-item index="3">
					<span @click="toAdvert">我的广告</span>
					<i class="el-icon-s-unfold"></i>
				</el-menu-item>
				<el-menu-item index="4">
					<span @click="toCF">发起众筹</span>
					<i class="el-icon-s-unfold"></i>
				</el-menu-item>
				<el-menu-item index="5">
					<span @click="selectUserAddress">我的地址</span>
					<i class="el-icon-s-unfold"></i>
				</el-menu-item>
			</el-menu>



		</div>
		<!-- 数据显示 -->
		<div style="width:60%; margin-top: 30px; float: right;">
			<router-view></router-view>
		</div>

		<!-- 实名认证申请弹出框 -->
		<!-- 账户类型选择的对话框 -->
		<el-dialog title="实名认证-账户类型选择" :visible.sync="dialogFormVisible" :before-close="reset">
			<el-row :gutter="20" class="zj">
				<el-radio-group v-model="cards.accountid" size="mini" style="margin-left: 13px" fill="#a0a0ff"
					v-for="(item,index) in AccountType" :key="index">

					<el-radio-button :label="item.accountid">
						<h2>{{item.account}}
						</h2>
						<el-image style="width: 100px; height: 100px" :src="imgurl + item.accountimg"></el-image>
					</el-radio-button>

				</el-radio-group>
			</el-row>
			<el-button type="danger" size="medium" style="width: 100%; padding: 10px 16px; font-size: 20px"
				@click="toOne">认证申请</el-button>
			<div class="container" style="margin-top: 20px">
				<div class="row clearfix">
					<div class="col-md-12 column">
						<div id="footer">
							<div class="footerNav">
								<a rel="nofollow" href="http://www.atguigu.com">关于我们</a> |
								<a rel="nofollow" href="http://www.atguigu.com">服务条款</a> |
								<a rel="nofollow" href="http://www.atguigu.com">免责声明</a> |
								<a rel="nofollow" href="http://www.atguigu.com">网站地图</a> |
								<a rel="nofollow" href="http://www.atguigu.com">联系我们</a>
							</div>
							<div class="copyRight">
								Copyright ?2017-2017atguigu.com 版权所有
							</div>
						</div>
					</div>
				</div>
			</div>
		</el-dialog>


		<!-- 填写基本信息的对话框 -->
		<el-dialog title="实名认证-申请" :visible.sync="oneDialog" width="40%" :before-close="reset">
			<!--实名认证申请的表单1 -->
			<el-form ref="addref" :rules="addrules" :model="cards" label-width="100px">
				<el-form-item label="姓名" prop="name">
					<el-input v-model="cards.name" placeholder="请填写姓名" style="width: 60%;"></el-input>
				</el-form-item>
				<el-form-item label="身份证号码" prop="idcard">
					<el-input v-model="cards.idcard" placeholder="请填写个人身份证号" style="width: 60%;"></el-input>
				</el-form-item>
			</el-form>
			<!-- 取消和确定按钮 -->
			<span slot="footer" class="dialog-footer">
				<el-button @click="reset" type="info">取消</el-button>
				<el-button @click="back" type="primary">上一步</el-button>
				<el-button @click="toTwo" type="primary">下一步</el-button>
			</span>
		</el-dialog>

		<!-- 实名认证第二步 -->
		<el-dialog title="实名认证-资质图片上传" :visible.sync="twoDialog" width="40%" :before-close="reset">
			<!--实名认证申请的表单1 -->
			<h2 style="color: #3C8DBC;">上传资质图片</h2>
			<el-form ref="addref" :rules="addrules" :model="cards" label-width="100px">
				<el-form-item label="">
					<!-- 图片上传 -->
					<!-- action:默认上传的路径 
			list-type：上传组件的样式
			on-preview：图片放大函数
			on-remove：图片移除的函数
			on-success：上传成功后的函数-->
					<el-upload action="http://localhost:8888/crowdfunding_system_war_exploded/upload"
						list-type="picture-card" :on-preview="handlePictureCardPreview" :on-remove="handleRemove"
						:on-success="addSuccess">
						<i class="el-icon-plus"></i>
					</el-upload>
					<!-- 图片放大后的对话框 -->
					<el-dialog :visible.sync="imgDialog">
						<img width="100%" :src="dialogImageUrl" alt="">
					</el-dialog>
				</el-form-item>
			</el-form>
			<!-- 取消和确定按钮 -->
			<span slot="footer" class="dialog-footer">
				<el-button @click="reset" type="info">取消</el-button>
				<el-button @click="backOne" type="primary">上一步</el-button>
				<el-button @click="toThree" type="primary">下一步</el-button>
			</span>
		</el-dialog>


		<!-- 短信认证 -->
		<el-dialog title="实名认证-电话验证" style="font-style: inherit; " :visible.sync="threeDialog" width="40%"
			:before-close="reset">
			<el-form ref="addref" :rules="addrules" label-width="100px" :model="cards">
				<el-form-item label="手机号" prop="phone">
					<el-input v-model="cards.phone" placeholder="请填写验证所用手机号" style="width: 60%;"></el-input>
					<el-button type="warning" icon="el-icon-search" @click="fa" style="float: right;">获取验证码</el-button>
				</el-form-item>
				<el-form-item label="验证码">
					<el-input v-model="cards.yzm" placeholder="请填写短信中收到的验证码" style="width: 60%;"></el-input>
					<el-button type="warning" icon="el-icon-search" @click="fa" style="float: right;">请重新获取</el-button>
				</el-form-item>
			</el-form>
			<!-- 取消和确定按钮 -->
			<span slot="footer" class="dialog-footer">
				<div align="left">
					<el-button @click="reset" type="info">取消</el-button>
					<el-button @click="backTwo" type="primary">上一步</el-button>
					<el-button @click="addCard" type="success" style="float: right;">申请完成</el-button>
				</div>

			</span>
		</el-dialog>

		<!-- ###########################地址添加显示 -->
		<el-dialog title="我的收货地址" :visible.sync="dialogVisible" width="60%" :before-close="handleClose">
			<el-button type="primary" @click="addDialogVisible = true">添加地址</el-button>
			<center>
				<el-table style="width: 100%;" :row-class-name="tableRowClassName" :data="address">
					<el-table-column prop="username" label="用户名" width="180">
					</el-table-column>
					<el-table-column prop="phone" label="电话" width="180">
					</el-table-column>
					<el-table-column prop="addname" label="地址" width="180">
					</el-table-column>
					<el-table-column label="操作">
						<!-- 作用域插槽 -->
						<template slot-scope="scope">
							<el-button type="danger" icon="el-icon-delete" size="mini"
								@click="delAddress(scope.row.addressid)"></el-button>

							<el-button type="success" @click="selectAddressDetaties(scope.row.addressid)"
								icon="el-icon-star-off" size="mini"></el-button>
						</template>
					</el-table-column>
				</el-table>
			</center>
			<!-- size-change:每页显示的条数改变时触发的函数
				      current-change：当前页码改变时触发的函数
				-->
			<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
				:current-page="queryinfo.pagenum" :page-sizes="[1, 2, 4, 5]" :page-size="queryinfo.pagesize"
				layout="total, sizes, prev, pager, next, jumper" :total="total">
			</el-pagination>

			<span slot="footer" class="dialog-footer">
				<center>
					<el-button @click="dialogVisible = false">关闭</el-button>
				</center>
			</span>
			<!-- 内置1 -->
			<el-dialog title="地址详情" :visible.sync="detatiesDialog" width="60%" :before-close="handleClose"
				append-to-body>
				<el-descriptions direction="vertical" :column="4" border label-class-name="my-label">
					<el-descriptions-item label="用户名" content-class-name="content1">
						{{deteties.username}}
					</el-descriptions-item>
					<el-descriptions-item label="手机号" content-class-name="content2">
						{{deteties.phone}}
					</el-descriptions-item>
					<el-descriptions-item label="居住地" content-class-name="content3">
						{{deteties.addname}}
					</el-descriptions-item>
					<el-descriptions-item label="详细地址" content-class-name="content4"
						:contentStyle="{'text-align': 'left'}">
						{{deteties.detaties}}
					</el-descriptions-item>
				</el-descriptions>
				<span slot="footer" class="dialog-footer">

					<el-button @click="levelDetaties">关闭</el-button>
					<el-button type="primary" @click="toUpdate(deteties.addressid)">修改</el-button>
				</span>
				<!-- 内置2 -->
				<!-- 修改地址信息的对话框 -->
				<!-- visible.sync:当前对话框是否显示
				     before-close:关闭前的提示-->
				<el-dialog title="修改用户信息" :visible.sync="updateDialogVisible" width="30%" :before-close="updatereset"
					append-to-body="true">
					<!--修改用户信息的表单 -->
					<el-form ref="updateref" :rules="addrules" :model="updateAddressObject" label-width="100px">
						<el-form-item label="电话" prop="phone">
							<el-input v-model="updateAddressObject.phone" style="width: 60%;"></el-input>
						</el-form-item>
						<el-form-item label="地址">
							<el-cascader v-model="addressAll" :options="cityData" :props="cityProp"
								@change="updateChange">
							</el-cascader>
						</el-form-item>
						<el-form-item label="详细地址" prop="detaties">
							<el-input v-model="updateAddressObject.detaties" style="width: 60%;"></el-input>
						</el-form-item>
					</el-form>
					<!-- 取消和确定按钮 -->
					<span slot="footer" class="dialog-footer">
						<el-button @click="updatereset">取 消</el-button>
						<el-button type="primary" @click="update">确定修改</el-button>
					</span>
				</el-dialog>
			</el-dialog>

			<!-- 添加信息的对话框 -->
			<!-- visible.sync:当前对话框是否显示
			     before-close:关闭前的提示-->
			<el-dialog title="添加用户信息" :visible.sync="addDialogVisible" width="30%" :before-close="addressreset"
				append-to-body="true">
				<!--添加用户信息的表单 -->
				<el-form ref="addressref" :rules="addrules" :model="insertAddress" label-width="100px">
					<el-form-item label="电话" prop="phone">
						<el-input v-model="insertAddress.phone" placeholder="请输入手机号" style="width: 60%;"></el-input>
					</el-form-item>
					<el-form-item label="地址">
						<el-cascader v-model="addressAll" :options="cityData" :props="cityProp" @change="addressChange">
						</el-cascader>
					</el-form-item>
					<el-form-item label="详细地址" prop="detaties">
						<el-input v-model="insertAddress.detaties" placeholder="请输入详细地址信息" style="width: 60%;">
						</el-input>
					</el-form-item>
				</el-form>
				<!-- 取消和确定按钮 -->
				<span slot="footer" class="dialog-footer">
					<el-button @click="addressreset">取 消</el-button>
					<el-button type="primary" @click="insert">确 定</el-button>
				</span>
			</el-dialog>

		</el-dialog>
		<!-- 查看实名认证状态 -->
		<el-dialog title="实名认证状态" :visible.sync="idCardStatusDialog" width="52.40%" :before-close="idstatus">
			<el-table id="smtable" :data="idcard" border style="width: 100%;">
				<el-table-column prop="username" label="申请账户" width="100">
				</el-table-column>
				<el-table-column prop="name" label="申请人" width="100">
				</el-table-column>
			<!-- 	<el-table-column label="资质图片" width="200">
					<template slot-scope="scope">
						<el-image style="width: 60px; height: 50px" :src="imgurl+scope.row.comfirmimg" :fit="fit">
						</el-image>
					</template>
				</el-table-column> -->
				<el-table-column prop="idcard" label="申请人身份证号" width="200">
				</el-table-column>
				<el-table-column prop="phone" label="手机号码" width="150">
				</el-table-column>
				<el-table-column label="审核状态" width="100">
					<template slot-scope="scope">
						<div v-show="scope.row.status==0" style="color: orange;">审核中</div>
						<div v-show="scope.row.status==1" style="color: green;">审核通过</div>
						<div v-show="scope.row.status==2" style="color: red;">未通过</div>
					</template>
				</el-table-column>
				<el-table-column prop="reason" label="审核失败原因" width="200">
				</el-table-column>
			</el-table>
			<span slot="footer" class="dialog-footer">
				<el-button @click="idstatus">关闭</el-button>
			</span>
		</el-dialog>
	</div>
</template>

<script>
	import qs from 'qs';
	import cityData from '../assets/citydata.js';
	export default {
		data() {

			// 地址添加方法
			var checkMobile = ((rule, value, callback) => {
				if (!value) { //value为空
					return callback(new Error('手机号不能为空'))
				}
				//判断是否符合手机号的正则表达式
				var reg = /^[1][0-9]{10}$/
				if (!reg.test(value)) {
					return callback(new Error('手机号格式不合法'))
				}
				return callback();
			});
			// 自定义邮箱验证的规则
			var checkEmail = ((rule, value, callback) => {
				if (!value) { //value为空
					return callback(new Error('邮箱不能为空'))
				}
				//判断是否符合邮箱的正则表达式
				var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/
				if (!reg.test(value)) {
					return callback(new Error('邮箱格式不合法'))
				}
				return callback();
			});
			var checkMobile = ((rule, value, callback) => {
				if (!value) { //value为空
					return callback(new Error('手机号不能为空'))
				}
				//判断是否符合手机号的正则表达式
				var reg = /^[1][0-9]{10}$/
				if (!reg.test(value)) {
					return callback(new Error('手机号格式不合法'))
				}
				return callback();
			});
			// 身份证号正则
			var checkIdCard = ((rule, value, callback) => {
				if (!value) { //value为空
					return callback(new Error('身份证号不能为空'))
				}
				//判断是否符合手机号的正则表达式
				var reg =
					/^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/
				if (!reg.test(value)) {
					return callback(new Error('身份证号格式不合法'))
				}
				return callback();
			});
			return {
				idcard: [],
				idCardStatusDialog: false,
				// 用户对象
				user: '',
				imgurl: 'http://localhost:8888/crowdfunding_system_war_exploded/showimg?filename=',
				// 短信验证
				// 实名认证申请
				cards: {
					userid: '',
					accountid: '',
					name: '',
					idcard: '',
					phone: '',
					yzm: '',
					zyzm: '',
					comfirmimg: '',
				},
				radio: "",
				AccountType: [],
				imgurl: 'http://localhost:8888/crowdfunding_system_war_exploded/showImg?filename=',
				// 实名认证账号类型选择对话框
				dialogFormVisible: false,
				// 实名认证第一步对话框
				oneDialog: false,
				// 实名认证第二步上传资质图片的对话框
				twoDialog: false,
				// 图片预览的路径
				dialogImageUrl: '',
				// 图片放大对话框
				imgDialog: false,
				// 实名认证第三步对话框
				threeDialog: false,
				addrules: {
					idcard: [{
						validator: checkIdCard,
						trigger: 'blur'
					}],
					phone: [{
						validator: checkMobile,
						trigger: 'blur'
					}],
					email: [{
						validator: checkEmail,
						trigger: 'blur'
					}]
				},
				cityData: cityData,
				queryinfo: {
					userid: '',
					pagenum: 1, //访问的页码
					pagesize: 4 //默认每页展示的条数
				},
				// 用户的地址列表
				dialogVisible: false,
				address: [],
				total: 0,
				// 保存地址详细信息
				deteties: {

				},
				// 详细地址信息
				detatiesDialog: false,
				// 修改地址信息
				updateDialogVisible: false,
				updateAddressObject: {
					addressid: '',
					userid: '',
					phone: '',
					addname: '',
					detaties: '',
					username: ''
				},
				addrules: {
					phone: [{
						validator: checkMobile,
						trigger: 'blur'
					}],

				},
				// 添加对话框
				addDialogVisible: false,
				insertAddress: {
					userid: '',
					phone: '',
					addname: '',
					detaties: ''
				},
				addressAll: [],
				cityProp: {
					value: 'value',
					label: 'label',
					children: 'children'
				}
			}
		},
		methods: {
			idstatus(){
				this.idCardStatusDialog=false
			},
			// 查询实名认证状态
			async selectIdCard() {
				let id = window.sessionStorage.getItem("userid")
				let res = await this.$http.post('selectIdCardById?id=' + id)
				if (res.data.code == 200) {
					this.idcard.push(res.data.data)
				} else {
					this.$message.error(res.data.message)
				}
			},
			async getUser() {
				// 获取user对象
				let id = window.sessionStorage.getItem("userid");

				let res = await this.$http.get("selectById?id=" + id);
				console.log(res.data.data)
				this.user = res.data.data;
			},
			handleOpen(key, keyPath) {

			},
			handleClose(key, keyPath) {

			},
			toAdvert() {
				if (this.user.idcardstatus == 1) {
					this.$router.push("/advert")
				} else {
					this.$message.error("请先实名认证")
				}
			},
			toidcard() {
				// 实名认证地址
				this.$router.push("/acctype")
			},
			toCF() {
				if (this.user.idcardstatus == 1) {
					// 去添加收货地址，下面是添加收货地址url
					this.$router.push("/start")
				} else {
					this.$message.error("请先实名认证")
				}
			},

			// ##################实名认证
			async selectAccountType() {
				var res = await this.$http.post("/selectAllAccountType");
				if (res.data.code == 200) {
					this.AccountType = res.data.data;

				} else {
					this.$message.info(res.data.message);
				}
			},
			toOne() {
				var num = 0;
				for (var i = 0; i < this.AccountType.length; i++) {
					if (this.cards.accountid == this.AccountType[i].accountid) {
						num++;
						break;
					} else {
						num = 0;
					}
				}
				if (num == 0) {
					alert("请选择账户类型")
				} else {
					this.dialogFormVisible = false;
					this.oneDialog = true;
				}

			},
			toTwo() {
				if (this.cards.name == '' || this.cards.idcard == '') {
					alert("请填写数据")
					this.oneDialog = true
				} else {
					this.$refs.addref.validate(async (bo) => {
						if (!bo) {
							alert("格式不正确，请检查")
							this.oneDialog = true
						} else {
							this.oneDialog = false;
							this.twoDialog = true;
						}
					})
				}
			},
			toThree() {
				if (this.cards.comfirmimg == '') {
					alert("请上传资质图片")
					this.twoDialog = true
				} else {
					this.twoDialog = false;
					this.threeDialog = true;
				}
			},
			back() {
				this.oneDialog = false;
				this.dialogFormVisible = true;
			},
			backOne() {
				this.twoDialog = false;
				this.oneDialog = true;
			},
			backTwo() {
				this.threeDialog = false;
				this.twoDialog = true;
			},
			reset() {
				this.dialogFormVisible = false
				this.oneDialog = false
				this.twoDialog = false
				this.threeDialog = false
				this.imgDialog = false
				this.cards.userid = ''
				this.cards.accountid = ''
				this.cards.name = ''
				this.cards.idcard = ''
				this.cards.phone = ''
				this.cards.yzm = ''
				this.cards.zyzm = ''
			},
			// 图片移除
			handleRemove(file, fileList) {
				// console.log(file, fileList);
				this.cards.comfirmimg = '';
			},
			// 图片放大
			handlePictureCardPreview(file) {
				this.dialogImageUrl = file.url;
				this.imgDialog = true;
			},
			// 图片上传成功后的函数
			addSuccess(response) {
				if (response.code == 200) {
					this.cards.comfirmimg = response.message;
				}
			},

			addCard() {
				this.$refs.addref.validate(async (bo) => {
					if (bo) {
						if (this.cards.yzm == this.cards.zyzm) {
							//关闭添加对话框
							this.threeDialog = false;
							this.cards.userid = window.sessionStorage.getItem("userid");
							var res = await this.$http.post('addCard', qs.stringify(this.cards));
							// 处理返回值信息，并给出不同的信息提示
							if (res.data.code == 400) { // 添加失败
								this.$message.error(res.data.message);
							} else {
								this.$message.success(res.data.message);
							}
							this.cards = '';
						} else {
							this.$message.error("验证码不正确")
						}
					} else {
						this.$message.error('格式不合法');
					}
				})
			},
			// 获取验证码
			async fa() {
				var pa = new URLSearchParams()
				pa.append("phone", this.cards.phone)
				var res = await this.$http.post('phoneYZ', pa);
				this.cards.zyzm = res.data.message;
				this.$message.success('验证码已发送！');
				this.threeDialog = true
			},

			// 地址########################
			handleClose(done) {
				this.$confirm('确认关闭？')
					.then(_ => {
						done();
					})
					.catch(_ => {});
			},
			async selectUserAddress() {
				this.queryinfo.userid = window.sessionStorage.getItem("userid");
				this.dialogVisible = true
				var res = await this.$http.post("selectUserAddress", qs.stringify(this.queryinfo));
				// console.log(res)
				if (res.data.code == 400) {
					this.$message.error(res.data.message);
				} else {
					if (res.data.data.list.length != 0) {
						this.address = res.data.data.list;
						this.total = res.data.data.total;
					}
				}
			},
			// 每页条数改变的函数
			handleSizeChange(newpagesize) {

				this.queryinfo.pagesize = newpagesize;
				this.queryinfo.pagenum = 1;
				this.selectUserAddress()
			},
			// 改变查询页数的函数
			handleCurrentChange(newpagenum) {
				this.queryinfo.pagenum = newpagenum;
				this.selectUserAddress()
			},
			tableRowClassName({
				row,
				rowIndex
			}) {
				if (rowIndex % 2 == 1) {
					return 'warning-row';
				} else if (rowIndex % 2 == 0) {
					return 'success-row';
				}
				return '';
			},
			async selectAddressDetaties(id) {
				this.detatiesDialog = true
				this.queryinfo.userid = window.sessionStorage.getItem("userid");
				var res = await this.$http.get('selectByAddressid?addressid=' + id + '&userid=' + this.queryinfo
					.userid);
				console.log(res.data)
				if (res.data.code == 200) {
					this.deteties = res.data.data;
				} else {
					this.$message.error('查询失败');
				}
				// console.log(this.deteties)
			},
			delAddress(id) {
				this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消',
					type: 'warning'
				}, ).then(async () => {
					this.queryinfo.userid = window.sessionStorage.getItem("userid");
					var res = await this.$http.get('deleteAddress?addressid=' + id + '&userid=' + this
						.queryinfo.userid);
					if (res.data.code == 200) {
						this.$message.success(res.data.message);
						this.selectUserAddress()
					} else {
						this.$message.error(res.data.message);
					}
				}).catch(() => {
					this.$message({
						type: 'info',
						message: '已取消删除'
					});
				});
			},
			// 修改对话框中的取消事件
			updatereset() {
				// 关闭对话框
				this.updateDialogVisible = false;
				this.$refs.updateref.resetFields();
				this.filelist = [];
			},
			// 修改确定
			update() {
				this.$refs.updateref.validate(async (bo) => {
					if (bo) {
						//关闭添加对话框
						this.updateDialogVisible = false;
						var res = await this.$http.post('updateAddress', qs.stringify(this
							.updateAddressObject));
						// 处理返回值信息，并给出不同的信息提示
						if (res.data.code == 400) { // 添加失败
							this.$message.error(res.data.message);
						} else {
							this.$message.success(res.data.message);
						}

						this.selectAddressDetaties(this.deteties.addressid)
					} else {
						this.$message.error('格式不合法');
					}
				})
			},
			async toUpdate(id) {
				//从后端根据id查询当前用户信息
				var res = await this.$http.get('selectAddressByid?addressid=' + id);
				if (res.data.code == 200) {
					// 赋予对象
					this.updateAddressObject = res.data.data;
					// 展示修改的对话框
					this.updateDialogVisible = true;
					console.log(this.updateAddressObject)
				} else {
					this.$message.error(res.data.message);
				}
			},
			// 添加地址确定
			insert() {
				this.$refs.addressref.validate(async (bo) => {
					if (bo) {
						this.addDialogVisible = false;
						this.insertAddress.userid = window.sessionStorage.getItem("userid")
						var res = await this.$http.post('addAddress', qs.stringify(this.insertAddress));
						// 处理返回值信息，并给出不同的信息提示
						if (res.data.code == 400) { // 添加失败
							this.$message.error(res.data.message);
						} else {
							this.$message.success(res.data.message);
						}

						this.selectUserAddress()
						this.$refs.addressref.resetFields();

					} else {
						this.$message.error('格式不合法');
					}
				})
			},
			addressreset() {
				this.addDialogVisible = false
				this.addressAll = []
				this.$refs.addressref.resetFields();
			},
			addressChange(value) {
				this.addressAll = value;
				var name = "";
				for (var i = 0; i < this.addressAll.length; i++) {
					name += this.addressAll[i] + ""
				}
				// this.addressAll.map((item) => (name += cityData[item] + "")); 
				this.insertAddress.addname = name;
				console.log(this.addressAll)
				console.log(this.insertAddress.addname)
			},
			updateChange(value) {
				this.addressAll = value;
				var name = "";
				for (var i = 0; i < this.addressAll.length; i++) {
					name += this.addressAll[i] + ""
				}
				// this.addressAll.map((item) => (name += cityData[item] + "")); 
				this.updateAddressObject.addname = name;
				console.log(this.addressAll)
				console.log(this.updateAddressObject.addname)
			},
			levelDetaties() {
				this.detatiesDialog = false;
				this.selectUserAddress()
			},
			tozc() {
				if (this.user.idcardstatus == 1) {
					this.$router.push("/zc")
				} else {
					this.$message.error("请先实名认证")
				}

			},
			tomzc() {
				this.$router.push("/tomzc")
			}

		},
		mounted() {
			this.getUser();
			this.selectAccountType();
			this.selectIdCard();
		}
	}
</script>

<style scoped="scoped">
	.el-menu-item {
		border-radius: 10px;
		border-bottom: solid;
		border-width: 1px;
	}

	.el-tabs--border-card {
		border-radius: 20px;
	}

	.el-tabs__nav-scroll {
		border-radius: 20px;
	}

	.el-tabs__nav {
		height: 70px;
	}

	.is-top {
		border-radius: 20px;
	}

	* {
		padding: 0;
		margin: 0;
	}

	.page-header {
		padding-bottom: 9px;
		margin: 40px 0 20px;
		border-bottom: 1px solid #eee;
	}

	.box-card {
		margin: 0 auto;
		padding-top: 20px;
		width: 100%;
		font-family: Cambria, Cochin, Georgia, Times, "Times New Roman", serif;
		font-size: 22px;
	}

	.zj {
		padding-bottom: 9px;
		margin: 40px 0 20px;
		border-bottom: 1px solid #eee;
	}

	.el-col {
		margin-top: 30px;
		font-size: 18px;
		padding-bottom: 40px;
	}

	h2 {
		padding: 10px;
		font-size: 30px;
	}

	#footer {
		padding: 15px 0;
		background: #fff;
		border-top: 1px solid #ddd;
		text-align: center;
		font-size: 14px;
	}

	a {
		color: #337ab7;
		text-decoration: none;
	}

	.el-radio-button__inner {
		border: none !important;
	}

	.el-image {
		width: 240px !important;
		height: 150px !important;
	}

	/* 地址################### */
	.my-label {
		background: #E1F3D8;
	}

	.content1 {
		width: 150px;
		background: #FDE2E2;
	}

	.content2 {
		width: 150px;
		background-color: aquamarine;
	}

	.content3 {
		width: 180px;
		background-color: antiquewhite;
	}

	.content4 {
		background-color: #7FFFD4;
	}

	.el-table .warning-row {
		background: #FDE2E2;
	}

	.el-table .success-row {
		background: #5adafa;
	}
	/* #smtable{
		width: 800px;
	} */
</style>
